package com.pktechan.manage.enumeration;

/**
 *  是否  枚举
 * Created by qx.zhangbj02320 on 2018/3/27.
 */
public enum YesOrNoEnum {
    NO(0, "0", false, "否"), YES(1, "1", true, "是");

    private int iCode;
    private String strCode;
    private String name;
    private boolean booleanCode;

    YesOrNoEnum(int iCode, String strCode, boolean booleanCode, String name) {
        this.iCode = iCode;
        this.strCode = strCode;
        this.name = name;
        this.booleanCode = booleanCode;
    }

    public static YesOrNoEnum getByICode(Integer code) {
        for (YesOrNoEnum yesOrNo : YesOrNoEnum.values()) {
            if (yesOrNo.getICode() == code) {
                return yesOrNo;
            }
        }
        return null;
    }

    public static String getByStrCode(String code) {
        for (YesOrNoEnum yesOrNo : YesOrNoEnum.values()) {
            if (yesOrNo.strCode.equals(code) ) {
                return yesOrNo.name;
            }
        }
        return null;
    }

    public static String getNameByICode(Integer code) {
        for (YesOrNoEnum yesOrNo : YesOrNoEnum.values()) {
            if (yesOrNo.getICode() == code ) {
                return yesOrNo.name;
            }
        }
        return null;
    }

    public int getICode() {
        return iCode;
    }

    public String getStrCode() {
        return strCode;
    }

    public boolean getBooleanCode() {
        return booleanCode;
    }

    public String getName() {
        return name;
    }
}
